{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f967ab07-8556-4854-ab38-604cd9d6a7b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "!cd ../../; ./scripts/full_build.sh"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e4b0a67f-a249-4b87-ae93-f7b98c46b1dc",
   "metadata": {},
   "outputs": [],
   "source": [
    "import ipyreact\n",
    "import pandas as pd\n",
    "import anywidget\n",
    "from pathlib import Path\n",
    "df = pd.DataFrame(\n",
    "    {'a':[111_111,  77_777, 777_777, 1_000_000, 2_111_111, 1_235_999],\n",
    "     'b':[111_111, 555_555,       0,    28_123,   482_388,     5_666]})\n",
    "ipyreact.define_module(\"buckaroo-js-core\", Path(\"../../packages/bundled-staging/buckaroo-js-core.rollup.bundle.js\"))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9f34cf8a-a77a-4bd5-a172-e99cb1698640",
   "metadata": {},
   "outputs": [],
   "source": [
    "from buckaroo.buckaroo_widget import BuckarooWidget"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b51f5640-563b-4946-8b2c-b3ad7a7f8a3c",
   "metadata": {},
   "outputs": [],
   "source": [
    "class BuckarooCSSWidget(anywidget.AnyWidget):\n",
    "    _css = Path(\"./../../packages/buckaroo-js-core/dist/style.css\")\n",
    "BuckarooCSSWidget()\n",
    "class IPYBuckaroo(BuckarooWidget, ipyreact.ValueWidget):\n",
    "    _esm=\"\"\"\n",
    "import * as React from \"react\";\n",
    "import { extraComponents } from \"buckaroo-js-core\";\n",
    "\n",
    "export default function({\n",
    "    df_meta, df_data_dict, df_display_args,\n",
    "    buckaroo_state, setBuckaroo_state,\n",
    "    buckaroo_options,\n",
    "    command_config,\n",
    "    operations, setOperations,\n",
    "    operation_results}) {\n",
    "      const set_buckaroo_state = setBuckaroo_state;\n",
    "      const on_operations = setOperations;\n",
    "      console.log(\"df_data_dict\", df_data_dict);\n",
    "      console.log(\"buckaroo_state\", buckaroo_state);\n",
    "      console.log(\"buckaroo_options\", buckaroo_options);\n",
    "      console.log(\"df_display_args\", df_display_args);\n",
    "\treturn (\n",
    "\t\t<div className=\"buckaroo_anywidget\">\n",
    "\t\t    <extraComponents.WidgetDCFCell\n",
    "\t                df_meta={df_meta}\n",
    "\t                df_data_dict={df_data_dict}\n",
    "                        df_display_args={df_display_args}\n",
    "\t                        buckaroo_state={buckaroo_state}\n",
    "\t\t\t\ton_buckaroo_state={set_buckaroo_state}\n",
    "\t                        buckaroo_options={buckaroo_options}\n",
    "\t\t\t\tcommand_config={command_config}\n",
    "\t\t\t\toperations={operations}\n",
    "\t\t\t\ton_operations={on_operations}\n",
    "\t\t\t\toperation_results={operation_results}\n",
    "\t\t\t/>\n",
    "\t\t</div>\n",
    "\t);\n",
    "};\n",
    "    \"\"\"\n",
    "IPYBuckaroo(df)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "state": {},
    "version_major": 2,
    "version_minor": 0
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
